home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / Glypha III Src Folder / Code ƒ / Main.c < prev    next >
Encoding:
Text File  |  1995-02-01  |  1.9 KB  |  102 lines  |  [TEXT/MPCC]

  1.  
  2. //============================================================================
  3. //----------------------------------------------------------------------------
  4. //                                Glypha III 1.0.1
  5. //                                by  Scheherazade
  6. //----------------------------------------------------------------------------
  7. //============================================================================
  8.  
  9.  
  10. #include "Externs.h"
  11. #include <Sound.h>
  12.  
  13.  
  14. #define kPrefsVersion            0x0001
  15.  
  16.  
  17. void ReadInPrefs (void);
  18. void WriteOutPrefs (void);
  19. void main (void);
  20.  
  21.  
  22. prefsInfo    thePrefs;
  23. short        wasVolume;
  24.  
  25. extern    Boolean        quitting, playing, pausing, evenFrame;
  26.  
  27.  
  28. //==============================================================  Functions
  29. //--------------------------------------------------------------  ReadInPrefs
  30.  
  31. void ReadInPrefs (void)
  32. {
  33.     short        i;
  34.     
  35.     if (LoadPrefs(&thePrefs, kPrefsVersion))
  36.         SetSoundVol(thePrefs.wasVolume);
  37.     else
  38.     {
  39.         thePrefs.prefVersion = kPrefsVersion;
  40.         thePrefs.filler = 0;
  41.         PasStringCopy("\pYour Name", thePrefs.highName);
  42.         for (i = 0; i < 10; i++)
  43.         {
  44.             PasStringCopy("\pNemo", thePrefs.highNames[i]);
  45.             thePrefs.highScores[i] = 0L;
  46.             thePrefs.highLevel[i] = 0;
  47.         }
  48.         GetSoundVol(&thePrefs.wasVolume);
  49.     }
  50.     
  51.     GetSoundVol(&wasVolume);
  52. }
  53.  
  54. //--------------------------------------------------------------  WriteOutPrefs
  55.  
  56. void WriteOutPrefs (void)
  57. {
  58.     if (!SavePrefs(&thePrefs, kPrefsVersion))
  59.         SysBeep(1);
  60.     SetSoundVol(wasVolume);
  61. }
  62.  
  63. //--------------------------------------------------------------  main
  64.  
  65. void main (void)
  66. {
  67.     long        tickWait;
  68.     
  69.     ToolBoxInit();
  70.     CheckEnvirons();
  71.     OpenMainWindow();
  72.     InitVariables();
  73.     InitSound();
  74.     InitMenubar();
  75.     ReadInPrefs();
  76.     
  77.     do
  78.     {
  79. //        DoIdleAnimation();
  80.         HandleEvent();
  81.         if ((playing) && (!pausing))
  82.             PlayGame();
  83.         else
  84.         {
  85.             tickWait = TickCount() + 2L;
  86.             evenFrame = !evenFrame;
  87.             DrawTorches();
  88.             CopyAllRects();
  89.             do
  90.             {
  91.             }
  92.             while (TickCount() < tickWait);
  93.         }
  94.     }
  95.     while (!quitting);
  96.     
  97.     KillSound();
  98.     ShutItDown();
  99.     WriteOutPrefs();
  100. }
  101.  
  102.